﻿/*
* ibio-develop
* Tue Oct 30 14:08:12 2007
*/

import mx.events.EventDispatcher;

class Dblclick extends MovieClip { 
	var m_firstClickTime:Number;
	var m_lastClickTime:Number;
	var m_isDouble:Boolean;
	var m_interval:Number;
	private var dispatchEvent:Function;
	
	function Dblclick() {
		EventDispatcher.initialize(this);
		Mouse.addListener(this);
		m_isDouble = false;
		//双击时间间隔
		m_interval = 300;
		
	}
	
	function set INTERVAL( value ){
		m_interval = value;
	}
	
    private function onMouseDown():Void {
		if(m_isDouble){
			m_firstClickTime = getTimer();
			m_isDouble = false;
		}else{
			m_lastClickTime = getTimer();
			m_isDouble = true;
		}
		//两次点击时间差在m_interval毫秒以内计为双击
		if ( Math.abs(m_lastClickTime - m_firstClickTime) < m_interval ) {
			//广播事件
			dispatchEvent({type:"dblclick"});
			trace("ibio->双击");
		}
	}
	
}
